package com.kefu.call.vo;

import java.util.List;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;

import com.google.common.collect.Lists;
import com.kefu.call.model.ActivityUserInfo;
import com.kefu.common.context.KefuContext;
import com.kefu.common.util.StreamUtil;
import com.kefu.common.vo.AbstractInsertVo;

import cn.hutool.core.util.IdUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author francis
 * @date 2021/05/22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "活动用户")
public class ActivityUserInfoInsertVo extends AbstractInsertVo<List<ActivityUserInfo>> {

	@NotEmpty
    @ApiModelProperty(value = "活动Id")
    private String activityId;
    @ApiModelProperty(value = "数据状态0 无效，1有效",hidden=true)
    private Integer dataStatus=1;
    
    private List<ActivityUserVo> userList;
    
    @Data
    public static class ActivityUserVo{
    	@NotEmpty
    	@Size(max = 32)
    	@ApiModelProperty(value = "用户ID")
    	private String userId;
    	
    	@NotEmpty
    	@Size(max = 32)
    	@ApiModelProperty(value = "用户姓名")
    	private String userName;
    }

    @Override
    public List<ActivityUserInfo> convert() {
    	List<ActivityUserInfo> list = Lists.newArrayList();
    	KefuContext context = KefuContext.getKefuContext();
    	for (ActivityUserVo user : userList) {
			ActivityUserInfo info = new ActivityUserInfo();
			info.setActivityId(activityId);
			info.setDataStatus(dataStatus);
			info.setUserId(user.getUserId());
			info.setUserName(user.getUserName());
			info.setActivityUserId(IdUtil.simpleUUID());
			info.setCreateTime(context.getNow());
			info.setCreateUser(context.getUserId());
			info.setUpdateTime(context.getNow());
			info.setUpdateUser(context.getUserId());
			info.setTenantId(context.getTenantId());
			list.add(info);
		}
	    return list;
	}
}